{extend name="public/layout"/}
{/block}
{block name="head"}
{/block}
{block name="content"}
<div class="row">
    <form class="form-horizontal" id="moduleForm" role="form" action="{:url('landing/edittplcont')}" method="post">
    <div class="col-md-10" style="padding-top: 20px;">
        {volist name="TplModuleFieldList" id="field"}
        <div class="form-group">
            <label class="col-sm-2 control-label">{$field['title']}</label>

            {switch name="field['type']"}
                {case value="text"}
                    <div class="col-sm-4">
                        <input type="text" name="{$field['name']}" value="{$field['value']}" class="form-control" />
                    </div>
                {/case}
                {case value="img"}
                <div class="col-sm-4">
                    <input type="text" name="{$field['name']}" value="{$field['value']}" class="form-control" />
                    <input type="button" class="btn btn-default upload-img" value="上传" />
                </div>
                {/case}
                {case value="button"}
                    <div class="col-sm-4">
                        <input type="text" name="{$field['name']}[text]" value="{$field['value']}" placeholder="按钮文案" class="form-control" />
                        <input type="radio" name="{$field['name']}[type]" value="option1" checked>
                        跳转
                        <input type="text" name="{$field['name']}[url]" value="" placeholder="跳转地址" class="form-control" />
                        <input type="radio" name="{$field['name']}[type]" value="option1" >
                        js
                        <input type="text" name="{$field['name']}[js]" value="" placeholder="js代码" class="form-control" />
                    </div>
                {/case}
                {case value="imgtext"}
                    <div class="col-sm-9">
                        <button type="button" class="btn  btn-primary btn-xs addimgtext" data-name="{$field['name']}">添加</button>
                        <table class="table table-bordered imgtexttable">

                        </table>


                    </div>
                {/case}
                {default/}
                    <div class="col-sm-4">
                        <input type="text" name="{$field['name']}" value="{$field['value']}" class="form-control" />
                    </div>
            {/switch}

            <span class="help-block">{$field['remark']}</span>
        </div>
        {/volist}


        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="button" class="btn btn-primary clicksub">提交</button>
                <button class="btn btn-info" onclick="javascript:history.back(-1);return false;">返 回</button>
            </div>
        </div>
    </div>
    </form>
    <div id="uploadfile" data-callback="1" style="display: none"></div>
</div>
{/block}
{block name="script"}
{load href='_STATIC_/common/validform/css/validform.css'/}
{load href='_STATIC_/common/validform/js/validform_v5.3.2_min.js'/}
{load href='_STATIC_/common/jquery.form.min.js'/}
{load href='_STATIC_/common/common.js'/}
{load href='_STATIC_/common/webuploader/webuploader.min.js'/}
{load href='_STATIC_/common/upload.js'/}
<script>

    $(function() {
        $("#moduleForm").Validform({
            btnSubmit:".clicksub",
            tiptype: 3,
            ignoreHidden: true,
            callback: function(form) {
                formAjax(form, $("#moduleForm").attr("url"),function(data){
                    layer.closeAll();
                    if(data.code ==1){
                        layer.msg(data.msg, {icon: 1});
                    }else{
                        layer.msg(data.msg, {icon: 5});
                    }
                });
                return false;
            }
        });

        $(".upload-img").click(function(){
            var butStr = 'upload-img';
            $("#uploadfile input").trigger('click');
        });

        $("#uploadfile").InitUploader({
            btntext: "上传图片",
            multiple: true,
            filesize: "10240000",
            sendurl: "http://api.woordee.com/upload/uploadfile.html",
            swf: "/public/static/common/webuploader/uploader.swf",
        });


        $(".addimgtext").click(function () {
            var trlength = $(".imgtexttable tr").length;
            var field_name = $(this).data("name");
            var addImgTexthtmlTpl = '<tr>\n' +
                '                       <td>\n' +
                '                           文案：\n' +
                '                           <input type="text" name="'+field_name+'[text]" value="" placeholder="文案" class="form-control" />\n' +
                '                       </td>\n' +
                '                       <td>\n' +
                '                           描述：\n' +
                '                           <input type="text" name="'+field_name+'[desc]" value="" placeholder="描述" class="form-control" />\n' +
                '                       </td>\n' +
                '                       <td>\n' +
                '                           图片：\n' +
                '                           <input type="text" name="'+field_name+'[img]" value="" class="form-control img_'+trlength+'" />\n' +
                '                           <input type="button" class="btn btn-default btn-sm upload-img'+trlength+'"  value="上传" />\n' +
                '                       </td>\n' +
                '                   </tr>'
            $(".imgtexttable").append(addImgTexthtmlTpl);
            $(".upload-img"+trlength).click(function(){
                $("#uploadfile input").trigger('click');
            });
        });




    })




</script>
{/block}



